﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class adm_vlg_yeuCauThanhToanEdit : System.Web.UI.Page
{
    VLGDataContext _db8 = new VLGDataContext();
    YeuCauChuyenKhoan _object = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Session["AID"] == null)
        //    Response.Redirect("login.aspx");
        if (IsPostBack) return;

        //if (!FUNCTION.CheckAmin())
        //{
        //    Panel_admin.Visible = false;
        //    Panel_avatar.Visible = false;
        //    Panel_Meta.Visible = false;
        //    Panel_trong.Visible = false;
        //}

        if (Request.QueryString["action"] == "edit")
        {
            ltr_action_name.Text = "Sửa chữa";
            _object = _db8.YeuCauChuyenKhoans.Select(cat => cat).Where(cat => cat.idYCCK == Convert.ToInt32(Request.QueryString["id"])).FirstOrDefault();



        }
        else
        {

            ltr_action_name.Text = "Thêm mới";
        }
        FillData();
    }
    public void FillData()
    {
        if (_object != null)
        {
            txtSoTien.Text = _object.soTien.ToString();
           
        }
    }
    protected void butt_save_Click(object sender, EventArgs e)
    {
        if (_object == null)
            _object = new YeuCauChuyenKhoan();
        if (Request.QueryString["action"] == "edit")
        {
            _object = _db8.YeuCauChuyenKhoans.Select(cat => cat).Where(cat => cat.idYCCK == Convert.ToInt32(Request.QueryString["id"])).FirstOrDefault();
        }
       // _object.soTien = Convert.ToDecimal(txtSoTien.Text);
        _object.idAcc = 1;
        _object.ngay = DateTime.Now;
        _object.status = false;
        if (Request.QueryString["action"] == "add")
        {
            _db8.YeuCauChuyenKhoans.InsertOnSubmit(_object);
        }

        _db8.SubmitChanges();

        Response.Redirect("yeuCauThanhToan.aspx");
    }
}